package com.inossem.warehousestorage_inossem.request.storage;

import android.content.Context;

import com.google.gson.Gson;
import com.inossem.warehousestorage_inossem.bean.storage.StorageManageMatrBean;
import com.inossem.warehousestorage_inossem.constant.RequestConstant;
import com.inossem.warehousestorage_inossem.listener.GsonBeanListener;
import com.inossem.warehousestorage_inossem.listener.StringRequestListener;
import com.inossem.warehousestorage_inossem.manage.RequestManage;
import com.inossem.warehousestorage_inossem.model.StringResponse;
import com.inossem.warehousestorage_inossem.request.Request;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by leij on 2017/6/12.
 */

public class StorageManageMaterialGetMaterielRequest extends Request {
    private static final String CONDITION = "condition";//查询条件

    private static final String WAREHOUSE_ID = "wh_id";//仓库ID

    public static String request(Context context, String condition, String warehouseId, GsonBeanListener gsonBeanListener) {
        String tag;
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put(CONDITION, condition);
            jsonObject.put(WAREHOUSE_ID, warehouseId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        String json = jsonObject.toString();
        String url = RequestManage.getUrl(context, RequestConstant.URL_STORAGE_MANAGE_MATERIAL_ADD_MATERIEL);
        tag = RequestManage.getHttpsPostWithLoading(context, url, json, new StringRequestListener() {
            @Override
            public void onSuccess(StringResponse stringRequestResponse) {
                Gson gson = new Gson();
                String json = stringRequestResponse.getResponseInfo();
                StorageManageMatrBean bean = gson.fromJson(json, StorageManageMatrBean.class);
                excuteJsonBeanNew(context, bean, gsonBeanListener);
            }
        });
        return tag;
    }

}
